package com.cskaoyan.market.controller;

import com.cskaoyan.market.db.domain.MarketFootprint;
import com.cskaoyan.market.db.domain.MarketGoods;
import com.cskaoyan.market.service.MarketFootprintService;
import com.cskaoyan.market.util.JacksonUtil;
import com.cskaoyan.market.util.ResponseUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @Author XuFeiLong
 * @DATE: 2023/4/3
 * @TIME: 17:49
 */
@RestController
@RequestMapping("wx/footprint")
public class WxFootprintController {

    @Autowired
    MarketFootprintService footprintService;


    @GetMapping("list")
    public Object list(Integer page, Integer limit, HttpSession session) {
        Integer id = (Integer) session.getAttribute("id");
        List<MarketGoods> resultList = footprintService.list(id,page, limit);
       return ResponseUtil.okList(resultList);
    }

    @PostMapping("delete")
    public Object delete(@RequestBody String id) {
        Integer id1 = JacksonUtil.parseInteger(id, "id");
        int code=footprintService.delete(id1);

        if(code==200){
            return ResponseUtil.ok();
        }
        return ResponseUtil.badArgumentValue();

    }
}
